import React from "react";
// 重定向改成了Navigate组件
import { Link, Routes, Route, Navigate } from "react-router-dom";

const Home = () => {
  return <div>这是首页</div>;
};
const About = () => {
  return <div>这是关于页</div>;
};

const App = () => {
  return (
    <>
      <h2>路由重定向-v6</h2>
      <ul>
        <li>
          <Link to="/home">首页</Link>
        </li>
        <li>
          <Link to="/about">关于页</Link>
        </li>
      </ul>

      <hr />

      <Routes>
        {/* Routes里面只允许有Route */}
        <Route path="/" element={<Navigate to="/home"></Navigate>}></Route>
        <Route path="/home" element={<Home />}></Route>
        <Route path="/about" element={<About />}></Route>
      </Routes>
    </>
  );
};

export default App;
